package com.hgy.crowd.handler;

import com.hgy.crowd.service.ProjectService;
import com.hgy.crowd.util.ResultEntity;
import com.hgy.crowd.vo.DetailProjectVO;
import com.hgy.crowd.vo.PortalTypeVO;
import com.hgy.crowd.vo.ProjectVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author He
 * @Date 2020/7/4 19:09
 */
@RestController
public class ProjectHandler {
    @Resource
    private ProjectService projectService;

    @RequestMapping("/save/project/vo")
    ResultEntity<String> saveProjectVORemote(@RequestBody ProjectVO tempProject,
                                             @RequestParam("memberId") Integer memberId) {
        ResultEntity<String> result = projectService.saveProjectVORemote(tempProject, memberId);
        return result;
    }


    @RequestMapping("/get/project/detail/remote/{projectId}")
    public ResultEntity<DetailProjectVO> getDetailProjectVORemote(@PathVariable("projectId") Integer projectId) {
        try {
            DetailProjectVO detailProjectVO = projectService.getDetailProjectVO(projectId);
            return ResultEntity.successWithData(detailProjectVO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("/get/portal/type/project/data/remote")
    public ResultEntity<List<PortalTypeVO>> getPortalTypeProjectDataRemote() {
        try {
            List<PortalTypeVO> portalTypeVOList = projectService.getPortalTypeVO();
            return ResultEntity.successWithData(portalTypeVOList);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultEntity.failed(e.getMessage());
        }
    }


}
